local ClientOHOH = _G.ClientOHOH;
local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerComponent(),script.Parent.Name);
local FunctionList = ClientOHOH.load.FunctionList();
local Good_Cfg=ClientOHOH.config.Goods


function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent)
    self.player=self.parent
    self.DataBase=self.player:GetComponent(_G.ClientOHOH.load.Client_PlayerDataComponent())
    self.handles={}
    for _, v in pairs(script.Parent.handle:GetChildren()) do
        self.handles[v.Name] =self.player:AddPrivateComponent(v)
    end
     self.player.RobuxBuyEvent:Connect(function(id,...)
        local cfg= Good_Cfg[id]
        local list=  self.player.CanNotRobuxBuyEvent:Action(id,cfg.gType)
        for k,v  in pairs(list) do
            if v then
                return false
            end
        end
        
        local handle=self.handles[cfg.gType]
        if  handle and handle.ClientBuy then
            return  handle:ClientBuy(id)
        else
            local r= self:Invoke(FunctionList.buy_goods,id,...)
            if r then
                self.player.RobuxBuyDoneEvent:Action(id,cfg.gType)
                return true
            end
            return false
        end
    end)

end;



function M.dtor(self)
	M.super.dtor(self);
end;

return M